Skip to content

BUG: SeriesGroupBy apply wrong name #46623

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged

Conversation

ma3da
Copy link
Contributor

@ma3da ma3da commented Apr 3, 2022

@ma3da ma3da force-pushed the GH46369_seriesgroupby_apply_wrong_name branch from da9d644 to afaa1c4 Compare April 3, 2022 11:58
@ma3da ma3da changed the title BUG: SeriesGroupBy apply wrong name (#46369) BUG: SeriesGroupBy apply wrong name Apr 3, 2022
@ma3da ma3da marked this pull request as ready for review April 3, 2022 13:22
@rhshadrach rhshadrach added Bug Groupby Apply Apply, Aggregate, Transform, Map labels Apr 5, 2022
Copy link
Member

@rhshadrach rhshadrach left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR; looks really good. One question.

@rhshadrach rhshadrach added this to the 1.5 milestone Apr 5, 2022
@@ -1317,3 +1317,15 @@ def test_apply_str_with_args(df, args, kwargs):
result = gb.apply("sum", *args, **kwargs)
expected = gb.sum(numeric_only=True)
tm.assert_frame_equal(result, expected)


def test_result_name_when_one_group():
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you parameterize this tests instead of looping

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

result = ser.groupby(["a", "a"]).apply(lambda x: x).name
expected = name

assert result == expected
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you tm.assert_series_equal and fully construct the expected series

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@ma3da ma3da force-pushed the GH46369_seriesgroupby_apply_wrong_name branch from afaa1c4 to 370d109 Compare April 6, 2022 23:26
Copy link
Member

@rhshadrach rhshadrach left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@ma3da ma3da force-pushed the GH46369_seriesgroupby_apply_wrong_name branch from 370d109 to 7d2198d Compare April 13, 2022 18:46
@rhshadrach
Copy link
Member

@ma3da - can you merge main.

@mroeschke
Copy link
Member

Failure is unrelated. Will need an approval from @jreback to move forward

values,
not_indexed_same=not_indexed_same,
override_group_keys=override_group_keys,
)
result.name = self.obj.name # GH #46369
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the issue comment is not necessary

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

@ma3da ma3da requested a review from jreback April 17, 2022 17:55
@jreback
Copy link
Contributor

jreback commented Apr 18, 2022

looks good can merge on green

@rhshadrach rhshadrach merged commit b6f21f3 into pandas-dev:main Apr 19, 2022
@rhshadrach
Copy link
Member

Thanks @ma3da!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Apply Apply, Aggregate, Transform, Map Bug Groupby
Projects
None yet
Development

Successfully merging this pull request may close these issues.

SeriesGroupBy.apply results in wrong name when there is a single group
4 participants